package com.hometeacher.api.service;

import com.hometeacher.api.model.User;
import com.hometeacher.api.repository.UsersRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ZhaoYuan
 * @data 02/04/2020 21:42
 */
@Slf4j
@Service
public class UserService {
    @Autowired
    UsersRepository usersRepository;

    public User findByPhoneNumber(String phoneNumber) {
        return usersRepository.findByPhoneNumber(phoneNumber);
    }
    public User findById(String id) {
        return usersRepository.findUserByUid(id);
    }
    public User findByUsername(User user){
        return usersRepository.findUserByUsername(user.getUsername());
    }

    public User save(User user){
        return  usersRepository.save(user);
    }

}
